/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

/**
 * <p>Project: jse2302 - ArrDemo
 * <p>Powered by webrx On 2023-06-29 16:11:42
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class ArrDemo {

    public static void main(String[] args) {
        //ArrayList
        long ss = System.currentTimeMillis();
        List<String> list = new ArrayList<>();
        for (int i = 0; i <= 1000000; i++) {
            list.add("hello - " + i);
        }
        long ee = System.currentTimeMillis();
        System.out.println("ArrayList first insert : " + (ee - ss) + "ms");

        ss = System.currentTimeMillis();
        //for (int i = 0; i <= 100000; i++) {
        //    String t = list.get(i);
        //}
        String t1 = list.get(800000);
        ee = System.currentTimeMillis();
        System.out.println("ArrayList read : " + (ee - ss) + "ms");

        //LinkedList
        ss = System.currentTimeMillis();
        LinkedList<String> link = new LinkedList<>();
        for (int i = 0; i <= 1000000; i++) {
            link.add("hello - " + i);
        }
        ee = System.currentTimeMillis();
        System.out.println("LinkedList first insert : " + (ee - ss) + "ms");

        ss = System.currentTimeMillis();
        //for(String str : link){
        //    String t2 = str;
        //}
        String t2 = link.get(800000);
        //for (int i = 0; i <= 100000; i++) {
        //    String t = link.get(i);
        //}
        ee = System.currentTimeMillis();
        System.out.println("LinkedList read : " + (ee - ss) + "ms");
    }

    public static void ex1(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.print("请输入（exit)程序退出:");
            String txt = sc.nextLine();
            if ("exit".equalsIgnoreCase(txt)) {
                break;
            }
            if (txt.matches("[\\u4e00-\\u9fa5]+")) {
                System.out.println("是中文");
            } else if (txt.matches("[a-zA-Z]+")) {
                System.out.println("是英文");
            } else if (txt.matches("\\d+")) {
                System.out.println("是数字");
            } else {
                System.out.println("其它符号");
            }

        }
    }
}
